home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / network / ncsasock / neti_in.h < prev    next >
Text File  |  1996-07-05  |  5KB  |  159 lines

  1. /*
  2.  * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution is only permitted until one year after the first shipment
  6.  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
  7.  * binary forms are permitted provided that: (1) source distributions retain
  8.  * this entire copyright notice and comment, and (2) distributions including
  9.  * binaries display the following acknowledgement:  This product includes
  10.  * software developed by the University of California, Berkeley and its
  11.  * contributors'' in the documentation or other materials provided with the
  12.  * distribution and in all advertising materials mentioning features or use
  13.  * of this software.  Neither the name of the University nor the names of
  14.  * its contributors may be used to endorse or promote products derived from
  15.  * this software without specific prior written permission.
  16.  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  17.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  18.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19.  *
  20.  *    @(#)in.h    7.10 (Berkeley) 6/28/90
  21.  */
  22.  
  23. /*
  24.  * Constants and structures defined by the internet system,
  25.  * Per RFC 790, September 1981.
  26.  */
  27.  
  28. /*
  29.  * Protocols
  30.  */
  31. #define    IPPROTO_IP        0        /* dummy for IP */
  32. #define    IPPROTO_ICMP        1        /* control message protocol */
  33. #define    IPPROTO_GGP        3        /* gateway^2 (deprecated) */
  34. #define    IPPROTO_TCP        6        /* tcp */
  35. #define    IPPROTO_EGP        8        /* exterior gateway protocol */
  36. #define    IPPROTO_PUP        12        /* pup */
  37. #define    IPPROTO_UDP        17        /* user datagram protocol */
  38. #define    IPPROTO_IDP        22        /* xns idp */
  39. #define    IPPROTO_TP        29         /* tp-4 w/ class negotiation */
  40. #define    IPPROTO_EON        80        /* ISO cnlp */
  41.  
  42. #define    IPPROTO_RAW        255        /* raw IP packet */
  43. #define    IPPROTO_MAX        256
  44.  
  45.  
  46. /*
  47.  * Local port number conventions:
  48.  * Ports < IPPORT_RESERVED are reserved for
  49.  * privileged processes (e.g. root).
  50.  * Ports > IPPORT_USERRESERVED are reserved
  51.  * for servers, not necessarily privileged.
  52.  */
  53. #define    IPPORT_RESERVED        1024
  54. #define    IPPORT_USERRESERVED    5000
  55.  
  56. /*
  57.  * Internet address (a structure for historical reasons)
  58.  */
  59. struct in_addr {
  60.     u_long s_addr;
  61. };
  62.  
  63. /*
  64.  * Definitions of bits in internet address integers.
  65.  * On subnets, the decomposition of addresses to host and net parts
  66.  * is done according to subnet mask, not the masks here.
  67.  */
  68. #define    IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
  69. #define    IN_CLASSA_NET        0xff000000
  70. #define    IN_CLASSA_NSHIFT    24
  71. #define    IN_CLASSA_HOST        0x00ffffff
  72. #define    IN_CLASSA_MAX        128
  73.  
  74. #define    IN_CLASSB(i)        (((long)(i) & 0xc0000000) == 0x80000000)
  75. #define    IN_CLASSB_NET        0xffff0000
  76. #define    IN_CLASSB_NSHIFT    16
  77. #define    IN_CLASSB_HOST        0x0000ffff
  78. #define    IN_CLASSB_MAX        65536
  79.  
  80. #define    IN_CLASSC(i)        (((long)(i) & 0xe0000000) == 0xc0000000)
  81. #define    IN_CLASSC_NET        0xffffff00
  82. #define    IN_CLASSC_NSHIFT    8
  83. #define    IN_CLASSC_HOST        0x000000ff
  84.  
  85. #define    IN_CLASSD(i)        (((long)(i) & 0xf0000000) == 0xe0000000)
  86. #define    IN_MULTICAST(i)        IN_CLASSD(i)
  87.  
  88. #define    IN_EXPERIMENTAL(i)    (((long)(i) & 0xe0000000) == 0xe0000000)
  89. #define    IN_BADCLASS(i)        (((long)(i) & 0xf0000000) == 0xf0000000)
  90.  
  91. #define    INADDR_ANY        (u_long)0x00000000
  92. #define    INADDR_BROADCAST    (u_long)0xffffffff    /* must be masked */
  93. #ifndef KERNEL
  94. #define    INADDR_NONE        0xffffffff        /* -1 return */
  95. #endif
  96.  
  97. #define    IN_LOOPBACKNET        127            /* official! */
  98.  
  99. /*
  100.  * Socket address, internet style.
  101.  */
  102. struct sockaddr_in {
  103.     u_char    sin_len;
  104.     u_char    sin_family;
  105.     u_short    sin_port;
  106.     struct    in_addr sin_addr;
  107.     char    sin_zero[8];
  108. };
  109.  
  110. /*
  111.  * Structure used to describe IP options.
  112.  * Used to store options internally, to pass them to a process,
  113.  * or to restore options retrieved earlier.
  114.  * The ip_dst is used for the first-hop gateway when using a source route
  115.  * (this gets put into the header proper).
  116.  */
  117.  
  118. #ifdef COMP_CODEWAR
  119. /** dgg, original...can't compile ip_opts { ... ip_opts }; in codewar ansi c */
  120. struct ip_opts {
  121.     struct    in_addr ip_dst;        /* first hop, 0 w/o src rt */
  122.     char    ipOpts[40];        /* actually variable in size */
  123. };
  124. #else
  125. struct ip_opts {
  126.     struct    in_addr ip_dst;         
  127.     char    ip_opts[40];         
  128. };
  129. #endif
  130.  
  131. /*
  132.  * Options for use with [gs]etsockopt at the IP level.
  133.  * First word of comment is data type; bool is stored in int.
  134.  */
  135. #define    IP_OPTIONS    1    /* buf/ip_opts; set/get IP per-packet options */
  136. #define    IP_HDRINCL    2    /* int; header is included with data (raw) */
  137. #define    IP_TOS        3    /* int; IP type of service and precedence */
  138. #define    IP_TTL        4    /* int; IP time to live */
  139. #define    IP_RECVOPTS    5    /* bool; receive all IP options w/datagram */
  140. #define    IP_RECVRETOPTS    6    /* bool; receive IP options for response */
  141. #define    IP_RECVDSTADDR    7    /* bool; receive IP dst addr w/datagram */
  142. #define    IP_RETOPTS    8    /* ip_opts; set/get IP per-packet options */
  143.  
  144. //
  145. // The network macros are in machine/endian.h for 4.3reno, but for 
  146. // sun compatibility, I placed them here- Charlie Reiman
  147. //
  148. #define ntohl(x) x
  149. #define ntohs(x) x
  150. #define htonl(x) x
  151. #define htons(x) x
  152.  
  153. #ifdef KERNEL
  154. extern    struct domain inetdomain;
  155. extern    struct protosw inetsw[];
  156. struct    in_addr in_makeaddr();
  157. u_long    in_netof(), in_lnaof();
  158. #endif
  159.